from dao.user_store import UserStore
from utils.date import get_date_now
import time


class UserService():

    def list(self):
        return UserStore().list()

    def find_by_name(self, name):
        return UserStore().find_by_name(name)

    def delete_by_name(self, name):
        UserStore().delete_by_name(name)
        return True

    def addUser(self, user):
        user.code = user.name + str(int(time.time()))
        user.createTime = get_date_now()
        user.updateTime = get_date_now()
        UserStore().save(user)
